<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
	<script src="../lib/template-web.js"></script>
	<script src="../lib/jquery.js"></script>
</head>

<body>
	<ul>

	</ul>

	<!-- <script type="text/template" id='tpl'>
		<% for(var i=0;i<newArr.length;i++){  %>
		<li>我是第4个li====<%=newArr[i].name%></li>
		<%}%>
	</script> -->

	<script type="text/template" id='tpl'>
		==={{filter(t,'YYYY-MM-DD')}}
		{{each newArr   item i }}
		<li>我是第4个li=={{item.name}}=={{i}}</li>
		{{/each}}
	</script>
	<script>
	
		template.defaults.imports.filter = (val, str) => {
			//console.log(val, str);
			if (str == 'YYYY-MM-DD') {
				return val.getFullYear() + '===' + (val.getMonth() + 1) + '===' + val.getDate()
			} else {
				return val.getFullYear() + '===' + (val.getMonth() + 1)
			}

		}
		console.log(template.defaults);
		var arr = [{
				id: 1,
				name: 'jack',
				age: 18
			},
			{
				id: 2,
				name: 'jack2',
				age: 19
			},
			{
				id: 3,
				name: 'jack3',
				age: 16
			},
		]
		var html = template('tpl', {
			newArr: arr,
			t: new Date()
		})

		$('ul').html(html)
	</script>


</body>

</html>
